package com.generator.database.readwriteseparate;
/**
 * 通过ThreadLocal将DataSource信息保存在线程中, 依赖AOP来切数据源
 * 2018-4-17 19:40:15
 * @author chenjinlong
 */
public class DynamicDataSourceHolder {
	public static final String MASTER_DATASOURCE = "dataSourceMaster";
	public static final String SLAVE_DATASOURCE = "dataSourceSlave";

	
	private static final ThreadLocal<String> DATASOURCE_HOLDER = new ThreadLocal<String>();

	public static void setDataSourceKey(String dataSourceKey) {
		DATASOURCE_HOLDER.set(dataSourceKey);
	}
	public final static String getDataSourceKey() {
		return DATASOURCE_HOLDER.get();
	}
	public final static void clearDataSourceKey() {
		DATASOURCE_HOLDER.remove();
	}
}